﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/OneColumn.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="TelerikStore.Default" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <section id="latest-products">
	    <h2>Latest Products</h2>
        <%-- clear:both need to be set to the Rotator to clear floats of the h2 --%>
        <telerik:RadRotator ID="LatestItemsRotator" runat="server" Width="960px" Height="168px" ItemWidth="320px" ItemHeight="168px" style="clear: both;">
            <ItemTemplate>
				    <a href='ProductView.aspx?Deal=<%# Eval("Id") %>' class="thumb">
					    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("SmallPictureUrl") %>' AlternateText='<%# Eval("Title") %>' />
				    </a>
				    <h3 class="title">
					    <asp:Literal ID="Literal1" runat="server" Text='<%# Eval("Title") %>' />
				    </h3>
				    <p class="price-and-buy">
					    <asp:Label ID="Label1" runat="server" Text='<%# Eval("ConvertedCurrentPrice", "{0:C}") %>' CssClass="price" />
				    </p>                
            </ItemTemplate>
        </telerik:RadRotator>
	</section>
    <div id="product-categories">
        <h2>
            Categories</h2>
        <telerik:RadListView ID="CategoryListView" runat="server" ItemPlaceholderID="CategoryPanel"
            AllowPaging="true" OnNeedDataSource="CategoryListView_NeedDataSource">
            <LayoutTemplate>
                <div class="product-categories">
                    <ul>
                        <asp:Panel ID="CategoryPanel" runat="server">
                        </asp:Panel>
                    </ul>
                </div>
                <telerik:RadDataPager ID="CategoryListViewPager" runat="server" PagedControlID="CategoryListView">
                    <Fields>
                        <telerik:RadDataPagerTemplatePageField>
                            <PagerTemplate>
                                <p class="paging simple-paging">
                                    <telerik:RadButton ID="CategoryPreviousButton" runat="server" Text="PREVIOUS"
                                        Skin="" CommandName="Page" CommandArgument="Prev" ButtonType="LinkButton">
                                        <Icon PrimaryIconCssClass="prev" PrimaryIconLeft="-5" PrimaryIconTop="1" />
                                    </telerik:RadButton>
                                    <telerik:RadButton ID="CategoryNextButton" runat="server" Text="NEXT"
                                        Skin="" CommandName="Page" CommandArgument="Next" ButtonType="LinkButton">
                                        <Icon SecondaryIconCssClass="next" SecondaryIconRight="-5" SecondaryIconTop="0" />
                                    </telerik:RadButton>
                                </p>
                            </PagerTemplate>
                        </telerik:RadDataPagerTemplatePageField>
                    </Fields>
                </telerik:RadDataPager>
            </LayoutTemplate>
            <ItemTemplate>
                <li>
                    <asp:HyperLink ID="CategoryLink" runat="server" Text='<%# Eval("Attribute(\"Text\").Value") %>'
                        NavigateUrl='<%# "CategoryView.aspx?Category=" + Eval("Attribute(\"Value\").Value") %>' />
                </li>
            </ItemTemplate>
        </telerik:RadListView>
        <div id="search-form">
            <telerik:RadTextBox ID="SearchBox" runat="server" EmptyMessage="Search an item..." AutoPostBack="true" OnTextChanged="PerformSearch">
                <ClientEvents OnKeyPress="searchBoxKeyPress" />
            </telerik:RadTextBox>
            <telerik:RadButton ID="SearchButton" runat="server" Text="Search" AutoPostBack="true"
                OnClick="PerformSearch" OnClientClicking="searchButtonClicking" />
            <br />
            <span id="SearchError">
                <!-- -->
            </span>
            <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="CategoryListView">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="CategoryListView" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManagerProxy>
        </div>
    </div>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function searchButtonClicking(sender, args)
            {
                var textBox = $find("<%=SearchBox.ClientID %>")
                if (textBox.get_value() == "") 
                {
                    args.set_cancel(true);
                }
            }

            function searchBoxKeyPress(sender, args) {

                var code = args.get_keyCode();
                if (code == 13 && sender.get_textBoxValue() == "") {
                    args.set_cancel(true);
                }
            }        
        </script>
    </telerik:RadScriptBlock>
</asp:Content>
